package entity

import "time"

// 实体类的3个
type TableFunc interface {
	//设置创建人id,创建时间,更新人id,更新时间
	Set4Col(operId int64, operTime time.Time)
	//设置更新人id,更新时间
	SetCreate2Col(operId int64, operTime time.Time)
	//设置创建人id,创建时间
	SetUpdate2Col(operId int64, operTime time.Time)
}

// 获取表名称
type TableName interface {
	TableName() string
}

//通用6大字段
type TableCol6 struct {
	TableFunc

	ID         int64 `gorm:"primaryKey"` // 默认情况下，名为 `Id` 的字段会作为表的主键
	IsDel      int8  `gorm:"default:0"`
	CreateId   int64
	CreateTime time.Time `gorm:"->;<-:create"` // 允许读和创建时写
	UpdateId   int64
	UpdateTime time.Time

}


func (tc6 TableCol6)  Set4Col(operId int64, operTime time.Time){
	tc6.CreateId = operId
	tc6.CreateTime = operTime
	tc6.UpdateId = operId
	tc6.UpdateTime = operTime
}


func (tc6 TableCol6)  SetCreate2Col(operId int64, operTime time.Time){
	tc6.CreateId = operId
	tc6.CreateTime = operTime
}


func (tc6 TableCol6)  SetUpdate2Col(operId int64, operTime time.Time){
	tc6.UpdateId = operId
	tc6.UpdateTime = operTime
}



//通用4大字段
type TableCol4 struct {
	TableFunc
	ID         int64 `gorm:"primaryKey"` // 默认情况下，名为 `Id` 的字段会作为表的主键
	IsDel      int8  `gorm:"default:0"`
	CreateId   int64
	CreateTime time.Time `gorm:"->;<-:create"` // 允许读和创建时写
}


func (tc4 TableCol4)  SetCreate2Col(operId int64, operTime time.Time){
	tc4.CreateId = operId
	tc4.CreateTime = operTime
}

//通用3大字段
type TableCol3 struct {
	TableFunc
	ID         int64 `gorm:"primaryKey"` // 默认情况下，名为 `Id` 的字段会作为表的主键
	CreateId   int64
	CreateTime time.Time `gorm:"->;<-:create"` // 允许读和创建时写
}


func (tc3 TableCol3)  SetCreate2Col(operId int64, operTime time.Time){
	tc3.CreateId = operId
	tc3.CreateTime = operTime
}
